'''
Author: your name
Date: 2020-11-06 16:24:21
LastEditTime: 2020-11-06 16:39:43
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath: \python-study\djangoS\app01\app01\Views\queryFirst.py
'''
from django.http import request
from django.shortcuts import render,HttpResponse
from Models.models import Book
from django.core import serializers
from django.db.models.query import QuerySet
import json

class queryFirst():
    def index(request):
        books = Book.objects.first()
        if(isinstance(books,QuerySet)):
            return HttpResponse(serializers.serialize('json',books))
        else:
            return HttpResponse(serializers.serialize('json',[books]))
